package com.aube.base.player;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by hill on 10/24.
 */
public class HighlightAngleIndicator extends View {

    private Paint mPaint;
    private Path mPath;

    public HighlightAngleIndicator(Context context) {
        this(context, null);
    }

    public HighlightAngleIndicator(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public HighlightAngleIndicator(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        mPaint = new Paint();
        mPaint.setAntiAlias(true);
        mPaint.setColor(0x66000000);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        int width = getWidth();
        int height = getHeight();

        if(width > 0) {
            if(mPath == null) {
                mPath = new Path();
                mPath.moveTo(width/2 - height, 0);
                mPath.lineTo(width/2 + height, 0);
                mPath.lineTo(width/2, height);
                mPath.close();
            }

            canvas.drawPath(mPath, mPaint);
        }
    }
}
